/* Name: CloseBtn
 * Author: Tom Dickman
 * Date: 5-29-12
 * Description: Button used to quit current game, and go back to main screen.
 * Revisions: See Subversion logs at http://code.google.com/p/software-engineering-2012/source/list
 */

import java.awt.Graphics2D;

public class CloseBtn extends Button {
	private int radius;
	private Sprite sprite;
	
	// Creates a close button at the given location
	public CloseBtn(int px, int py, int pRadius) {
		super(px, py, pRadius);
		Game.create((Item)this, 1000000); // Needed for update, draw, and destroy
		colType = COL_NONE; // Needed for collision checking
		radius = pRadius;
	}
	
	// Called when mouse is pressed on button
	protected void pressed() {
		Sound.stopEffect(Sound.EFFECT_FUELALARM);
		Sound.stopMusic();
		Sound.effect(Sound.EFFECT_CLICK);
		Game.appendLog("Round Ended");
		Game.isPaused = false;
		Game.gotoRoom(Game.ROOM_START);
		Sound.playMusic(Sound.MUSIC_TITLE);
	}
	
	// Called whenever a new frame is drawn on the screen - draws button
	public void draw() {
		Graphics2D gh = Game.getGraphicsHandle();
		sprite = Sprite.load("/sprites/Buttons/close.png");
		//FontRenderContext frc = gh.getFontRenderContext();
		//Rectangle2D rect = gh.getFont().getStringBounds(text, frc);
		//gh.drawChars(text.toCharArray(), 0, text.length(), (int)(x + width/2 - rect.getWidth()/2), (int)(y + height/2 + rect.getHeight()/2)-10);
		sprite.draw(gh, x, y);
	}
	
	public void update() {updateBtn();}
	public void leftMousePress() {leftMousePressBtn();}
	public void leftMouseRelease() {leftMouseReleaseBtn();}
}